
jQuery(function($) {
  var Result = function() {
    this.checkHash(this.loadData)
  }

  Result.prototype.checkHash = function(callback) {
    var search = window.location.search.slice(1)
    if (!search) {
      return alert('缺少参数！')
    }
    var responseCode, mNo
    search = search.split('&')
    search.forEach(function(str) {
      str = str.split('=')
      if (str[0] === 'responseCode') {
        responseCode = str[1]
      } else if (str[0] === 'mNo') {
        mNo = str[1]
      }
    })
    if (!responseCode || !mNo) {
      return alert('缺少参数！')
    }
    callback.call(this, responseCode, mNo)
  }

  Result.prototype.loadData = function(responseCode, mNo) {
    if (responseCode === '0000') {
      $('.result-bin').addClass('result-success').find('h2').text('签约成功')
      $('.result-bot').addClass('result-success')
    } else {
      $('.result-bin').addClass('result-fail').find('h2').text('签约失败')
      $('.result-bot').addClass('result-fail')
    }
    $('#mnumber').text(mNo)
  }

  return new Result
})